package com.ghck.server.service.impl;
import java.util.List;

import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ghck.server.dao.PatientEventCategoryDictMapper;
import com.ghck.server.model.PatientEventCategoryDict;
import com.ghck.server.model.query.PatientEventCategoryDictQuery;
import com.ghck.server.service.PatientEventCategoryDictService;

/**
 * 数据类型  <br>
 * dict_patient_event_category <br>
 * v1.0 2016-05-01
 */
 @Service
 @Transactional
 public class PatientEventCategoryDictServiceImpl implements PatientEventCategoryDictService {
	
	private static final Logger logger = LoggerFactory.getLogger(PatientEventCategoryDictServiceImpl.class);
	
	@Autowired
	private PatientEventCategoryDictMapper patientEventCategoryDictMapper;
	
	/**
 	*根据ID删除 数据类型
 	*/
 	@Override
 	public Integer deletePatientEventCategoryDictById(Integer id){
 		return patientEventCategoryDictMapper.deleteById(id);
 	}
 	
 	/**
 	*新增 数据类型
 	*/
 	@Override
 	@Transactional
 	public Integer batchInsertPatientEventCategoryDict(List<? extends PatientEventCategoryDict> patientEventCategoryDicts){
		Integer count = patientEventCategoryDictMapper.batchInsert(patientEventCategoryDicts);
		return count;
 	}
 	/**
 	*新增 数据类型
 	*/
 	@Override
 	@Transactional
 	public Integer insertPatientEventCategoryDict(PatientEventCategoryDict domain){
		Integer id = patientEventCategoryDictMapper.insert(domain);
		return id;
 	}

 	/**
 	*更新 数据类型
 	*/
 	@Override
 	@Transactional
 	public Integer updatePatientEventCategoryDict(PatientEventCategoryDict domain){
		Integer count = patientEventCategoryDictMapper.update(domain);
		return count;
 	}
 	
 	/**
 	*根据ID查询 数据类型
 	*/
 	public PatientEventCategoryDict findPatientEventCategoryDictById(Integer id){
 		PatientEventCategoryDict result = patientEventCategoryDictMapper.findById(id);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
 	}

	/**
 	*通过query 查询 数据类型
 	*/
	public List<PatientEventCategoryDict> findPatientEventCategoryDictByQuery(PatientEventCategoryDictQuery query){
		query.dealWith();
		List<PatientEventCategoryDict> result = patientEventCategoryDictMapper.findByQuery(query);
		if(CollectionUtils.isNotEmpty(result)) {
			for (PatientEventCategoryDict patientEventCategoryDict : result) {
				patientEventCategoryDict.dealWith();
			}
		}
		return result;
	}	
	
	/**
 	*通过query count总条数
 	*/
 	public Integer countPatientEventCategoryDictByQuery(PatientEventCategoryDictQuery query){
 		query.dealWith();
 		Integer result = patientEventCategoryDictMapper.countByQuery(query);
 		return result;
 	}
 	
 	/**
 	* 通过ids查询
 	*/
 	public List<PatientEventCategoryDict> findPatientEventCategoryDictByIds(List<Integer> ids){
 		List<PatientEventCategoryDict> result = patientEventCategoryDictMapper.findByIds(ids);
		if(CollectionUtils.isNotEmpty(result)) {
			for (PatientEventCategoryDict patientEventCategoryDict : result) {
				patientEventCategoryDict.dealWith();
			}
		}
		return result;
 	}
 	
 	/**
 	*根据name查询 身体部位
 	*/
	public PatientEventCategoryDict findByName(String name){
		PatientEventCategoryDict result = patientEventCategoryDictMapper.findByName(name);
 		if(result!=null){
 			result.dealWith();
 		}
 		return result;
	}
	
	/**
 	*获取所有字典 身体部位
 	*/
	public List<PatientEventCategoryDict> findAll(){
		List<PatientEventCategoryDict> result = patientEventCategoryDictMapper.findAll();
		if(CollectionUtils.isNotEmpty(result)) {
			for (PatientEventCategoryDict patientEventCategoryDict : result) {
				patientEventCategoryDict.dealWith();
			}
		}
		return result;
	}
}	